<?php
include_once(dirname(__FILE__) . "/service-adapter-base.php");
include_once(dirname(__FILE__) . "/util.php");
include_once(dirname(__FILE__) . "/account/account.php");

class FavoriteServiceAdapter extends ServiceAdapterBase {
  function __construct() {
    parent::__construct('127.0.0.1', '9095');
    $this->service_ = new FavoriteServiceClient($this->protocol_);
  }

  protected function LoadIDL() {
    require_once dirname(__FILE__) . '/gen-php/ServiceBase/ServiceBase.php';
    require_once dirname(__FILE__) . '/gen-php/ServiceBase/ServiceBase_types.php';
    require_once dirname(__FILE__) . '/gen-php/FavoriteService/FavoriteService.php';
    require_once dirname(__FILE__) . '/gen-php/FavoriteService/FavoriteService_types.php';
  }

  public function Add($member, $article) {
    try {
      return $this->service_->Add($member, $article);
    } catch (TException $tx) {
      return -1;
    }
  }

  public function Remove($member, $article) {
    try {
      return $this->service_->Remove($member, $article);
    } catch (TException $tx) {
      return -1;
    }
  }

  public function GetMemberFavoriteArticles($member) {
    try {
      return $this->service_->GetMemberFavoriteArticles($member);
    } catch (TException $tx) {
      return null;
    }
  }

  public function GetArticleFavoriteMembers($article) {
    try {
      return $this->service_->GetArticleFavoriteMembers($article);
    } catch (TException $tx) {
      return null;
    }
  }
}
?>
